package com.attendancesystem.service;

import com.attendancesystem.model.Admin;
import com.attendancesystem.util.JDBCUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

public class AdminInfoService {
    public Admin getAllAdminInfo(String adminName)
    {
        Admin admin = new Admin();
        String sql = "select * from administrators where username like '%"+adminName+"%'";
        try(Connection con = JDBCUtils.getConnection();

            Statement stmt = con.createStatement();

            ResultSet rs = stmt.executeQuery(sql)){
            while (rs.next()) {
                admin.setAdminId(rs.getString("admin_id"));
                admin.setUsername(rs.getString("username"));
                admin.setPassword(rs.getString("password"));
                admin.setFullName(rs.getString("full_name"));
                admin.setDepartment(rs.getString("department"));
                admin.setContactPhone(rs.getString("contact_phone"));
                admin.setEmail(rs.getString("email"));
                admin.setOffice(rs.getString("office"));


            }


        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        return admin;


    }
}
